package com.yswee.mallnavi.view.food.hor;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import com.yswee.framework.widget.adapterview.MHorizontalListView;
import com.yswee.framework.widget.layoutview.ILayoutView;
import com.yswee.mallnavi.entity.info.InfoEntity;
import com.yswee.mallnavi.view.food.IGridView;
import com.yswee.mallnavi.view.food.grid.GridItem;

public class HorizontalListView extends MHorizontalListView<InfoEntity> implements IGridView {

    private IGridView.IActionCallback mActionCallback;

    @Override
    public void setActionCallback(IGridView.IActionCallback c) {
        mActionCallback = c;
    }

    private IGridView.IActionCallback mActionCallbackProxy = new IGridView.IActionCallback() {
        @Override
        public void onInfoClicked(View v, InfoEntity info) {
            if (mActionCallback != null) {
                mActionCallback.onInfoClicked(v, info);
            }
        }
    };

    public HorizontalListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected int getListViewType() {
        return LISTVIEW_TYPE_VIEW;
    }

    @Override
    protected ILayoutView<InfoEntity> getLayoutView(int position, InfoEntity t, int itemViewType) {
        GridItem griditem = new GridItem(mContext);
        griditem.setActionCallback(mActionCallbackProxy);
        return griditem;
    }
}
